Allow the use of absolute paths for loras and embeddings#820
Allow the use of absolute paths for loras and embeddings#820rmatif wants to merge 2 commits intoleejet:masterfrom
Conversation
|
Note this could have security implications: for instance, for web servers that call the library directly. It may be better to explicitly enable this support through a context flag, even if it ends up fixed as true on Another possibility could be turning |
The current implementation already has a similar problem, since it can parse arbitrary relative paths (allowing to escape the lora model dir with |
You just filter the prompt on the server side to remove the tags, and you stay safe
I had already thought of that, but when you’re dealing with many directories and some of them have thousands of subfolders, it becomes impractical. This lazy way is the easiest
I agree but it’s more useful in the API than in main.cpp, which remains something for personal use. At a certain point we do need to make |
At the very least I think the LoRAs+weights should be extracted from the prompt outside of the generate_image() function. Maybe having a function to parse the prompt and extract LoRAs can be useful to expose as part of the API, but I don't really like the way it's done right now. Off topic, but this also makes me think having a lower-level (cpp?) API to make more complex workflows without touching the library code would be nice. |
This PR adds support for using absolute paths for loras and embeddings. When an absolute path is detected, it overrides
--lora-model-dirand--embed-dirAdditionally, a new tag has been added to improve detection and handling of embeddings. Previously the code was case-sensitive to filenames and failed to load models containing uppercase characters
This feature is especially useful when managing many loras and embeddings spread across multiple folders and disks
Example usage:
./build/bin/sd -m path/to/model/model.safetensors -p "<embed:/path/to/embed/embed1.safetensors>, cute cat, <embed:/path/to/embed/embed2.safetensors> <lora:/path/to/lora/lora.safetensors:1>"